Repository navigation
Refuse a whole-number float in an integer field at config validate - #603
Conversation
A Domain with spec.proxy.upstream.port: 8100.0 (or maxRequestBodyMegabytes: 55.0) passes config validate today, then the value object raises TypeError in the command that reads it. These tests fail until the schema validator's integer type refuses floats. Part of #602 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The schema catalog built a stock Draft202012Validator, whose integer type accepts 8100.0. Such a value passed config validate, then the value object raised TypeError and the command that read it crashed. The catalog's validators now use a 2020-12 validator whose integer accepts only a Python int (still refusing bool), so the error is a schema error with the field's path. The value objects' TypeError stays as the second line of defence. Fixes #602 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A config that wrote an integer as a whole-number float validated before and now fails config validate, so D-14 puts the entry under Breaking, with the step a user takes before upgrading. Part of #602 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@romamo Decided without waiting: Why: Q-1 says a config that validates must not crash a later command, and every such value in a field read through a value object already crashed with Reply with a comment starting with |
RetainReleases.from_boundary coerced an integral float such as 2.0 to an int, because the stock JSON Schema integer let it through validation. With the strict integer type checker (#602), 2.0 no longer validates, so the coercion is dead and the value object now refuses it with TypeError like the other integer value objects. The 2.0 and 5.0 cases move from the inventory test to the refused values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
spec.deployment.retainReleases: 2.0 validated and read as 2 before #602; it is the one integer field where a whole-number float worked, so the entry names it as the value to fix before upgrading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Review of #603 at 7015bf1: MERGE AFTER SMALL FIX
Both CI jobs failed on sdk/tests/test_retain_releases.py::test_the_inventory_carries_the_count_five_when_absent[2.0-2] and [5.0-5]. The failure comes from this PR. On main, retainReleases: 2.0 validated and read as 2 on purpose (RetainReleases.from_boundary coerced a whole-number float). So the decided comment's premise, that every such value already crashed, doesn't hold for this one field: a config with retainReleases: 2.0 worked before and now stops validating. That still falls inside the decision ("any integer field", listed under Breaking, Q-3), so the review brings the code in line instead of exempting the field.
Fixes pushed:
- 0054ce0:
sdk/src/cloudfall/domain.pyRetainReleases.from_boundaryno longer coerces an integral float;sdk/tests/test_retain_releases.pymoves2.0to the refused cases and the value object's refused list, which fails on the old coercion - 7015bf1:
changelog.d/602-strict-integer.mdnamesspec.deployment.retainReleasesas the one field where2.0used to work, with its upgrade step
Checks: rebase onto main was a no-op; changelog_guard.py check exits 0; ruff check, mypy, config validate --project config/examples pass; the strict-integer, retain-releases, validation and request-body-limit tests pass (87). The full suite runs in CI.
Test proof: PROVEN (fix).
Not fixed (nits):
- F-1
sdk/src/cloudfall/investigation.py:727checks tool arguments with the stockDraft202012Validator; no tool schema has an integer today, so nothing reads differently - F-2 the plan's
Tests changed:line now namessdk/tests/test_retain_releases.pywith its reason - F-3
ruff format --checkalready fails across the repo on main; CI doesn't run it
History: H-2 consistent (a Breaking entry for a config that stops validating); H-1, H-3 to H-7 unrelated.
Plan
sdk/tests/test_strict_integer.py(new),sdk/src/cloudfall/validation.py,changelog.d/602-strict-integer.md; review fix:sdk/src/cloudfall/domain.py,sdk/tests/test_retain_releases.pyspec.proxy.upstream.portand inspec.proxy.maxRequestBodyMegabytesis refused byconfig validatewith its field path; plain integers still pass;trueis still refused); then buildSchemaCatalog's validators from aDraft202012Validatorextended with a strictintegertype checker, with its changelog fragmentuv run pytest sdk/tests/test_strict_integer.pyfails on main and passes with the fix;sdk/tests/test_validation.py,sdk/tests/test_domain_request_body_limit.pyand the other validation tests stay green;uv run cloudfall config validate --project config/examplespassessdk/tests/test_retain_releases.py: it asserted thatretainReleases: 2.0validates and reads as 2, the one integer field that coerced a whole-number float; under this change2.0is refused like every other integer field, so its cases move from the accepted to the refused listsSummary
SchemaCatalogbuilt a stockDraft202012Validator, whoseintegertype accepts a float with a zero fractional part. A Domain withspec.proxy.upstream.port: 8100.0passedcloudfall config validate, then the value object (_required_bounded_integer) raisedTypeErrorand the command that read it, such ascloudfall domains apply, failed withHANDLER_CRASHED.The catalog now builds its validators from
jsonschema.validators.extend(Draft202012Validator, type_checker=...), whoseintegeraccepts only a Pythonintand still refusesbool. Every integer field of every schema refuses8100.0atconfig validate, reported asschema_validation_failedwith the field's path, like any other schema error.check_schemastill checks each schema against the 2020-12 metaschema, and$refs resolve through the same strict validator class. The value objects'TypeErrorstays as the second line of defence.Behaviour change: a project that writes a whole-number float in any integer field now fails
config validate. For every field but one, such a value passed and then crashed the command that read it. The exception is a Component'sspec.deployment.retainReleases:RetainReleases.from_boundaryturned2.0into 2, soretainReleases: 2.0validated and worked on main. It is now refused like the rest, and the value object no longer coerces it (review fix). No example or fixture writes an integer as a float.The changelog entry is under
### Breaking, as D-14 requires for a change after which a config that validated before stops validating, and namesretainReleasesand the step a user takes before upgrading.Test notes
sdk/tests/test_strict_integer.py, failing on main, passing heresdk/tests/test_retain_releases.py, where2.0joins the refused values and the value object's refused list (the latter fails on the old coercion)uv run ruff check .,uv run mypy,uv run cloudfall config validate --project config/examples, and the validation and retain-releases test files; the full suite is left to CIFixes #602
🤖 Generated with Claude Code